<template>
   <div id="login">
        <h3>登录页面</h3>
        账户：<input type="text" v-model="userName"><br><br>
        密码：<input type="text" v-model="userPass"><br>
        <button @click="login">登录</button>
   </div>
</template>

<script>
    
    export default {
        data(){
            return{
                userName:'',
                userPass:''
            }
        },
        methods: {
            login() {
                //通过window对象给uname和upass进行赋值
                var name = window.uname = "admin";
                var pass = window.upass = "123";
                if(this.userName == name && this.userPass == pass){
                    alert("登录成功");
                    //重新跳转到首页
                    this.$router.replace('/');
                }else{
                    alert("账户密码不对");
                }


            }
        }
    }
</script>

<style>

</style>